package org.jeecg.modules.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.pz.cloud.framework.base.dao.CommonDao;
import com.pz.cloud.framework.model.SqlBuilder;
import org.apache.commons.lang.StringUtils;
import org.jeecg.modules.system.entity.SysDictItem;
import org.jeecg.modules.system.mapper.SysDictItemMapper;
import org.jeecg.modules.system.service.ISysDictItemService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @Author zhangweijian
 * @since 2018-12-28
 */
@Service
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements ISysDictItemService {

    @Autowired
    private SysDictItemMapper sysDictItemMapper;
    @Autowired
    private CommonDao commonDao;

    @Override
    public List<SysDictItem> selectItemsByMainId(String mainId) {
        return sysDictItemMapper.selectItemsByMainId(mainId);
    }

    @Override
    public List<SysDictItem> selectItemsByDictCodeAndItemText(String dictCode, String itemText) {
        SqlBuilder sqlBuilder = SqlBuilder.init("select i.* from sys_dict_item i  inner join sys_dict d on i.dict_id = d.id where i.item_text = :itemText and d.dict_code = :dictCode");
        sqlBuilder.setParms("dictCode",dictCode).setParms("itemText",itemText).returnType(SysDictItem.class);
        return commonDao.findList(sqlBuilder);
    }
}
